﻿/// <reference path="/Scripts/jquery-1.5.1-vsdoc.js" />
/// <reference path="/Scripts/jquery.validate-vsdoc.js" />
$(document).ready(function () {
    $('form').validate({
        rules: {
            Name: 'required',
            Address: 'required',
            ConstructionCompany: 'required',
            ConstructionProjectManager: 'required',
            ConstructionProjectManagerPhoneMobile: 'required',
            ConstructDateTime: 'required',
            High: 'required',
            InspectNO: 'required'
        },
        messages: {
            Name: '请输入机构名称',
            Address: '机构地址不能为空',
            ConstructionCompany: '施工单位不能为空',
            ConstructionProjectManager: '项目经理不能为空',
            ConstructionProjectManagerPhoneMobile: '联系电话不能为空',
            ConstructDateTime: '安装日期不能为空',
            High: '安装高度不能为空',
            InspectNO: '报检号不能为空'
        }
    });

    $('#ConstructDateTime, #DemolitionDateTime, #InspectTime').datepicker();


    //install company
    $("#DemolitionCompany").autocomplete({
        source: "/Company/Suggestion?type=install",
        minLength: 1,
        select: function (event, ui) {
            $('#DemolitionCompany').val(ui.item.label);
            $('#DemolitionCompanyId').val(ui.item.Data.Id);
            $('#DemolitionCompanyOwner').html(ui.item.Data.Legal);
            $('#DemolitionCompanyOwnerPhone').html(ui.item.Data.Phone);
            return false;
        },
        focus: function (event, ui) {
            $('#DemolitionCompany').val(ui.item.label);
            return false;
        }
    });



});